/**
 * 合并多个 reducer 函数为一个
 * @param {Object} reducers - 包含多个 reducer 函数的对象
 * @returns {Function} 返回一个合并后的 reducer 函数
 */
const combineReducers = (reducers) => {
	let reducersKeys = Object.keys(reducers)
	return (state, action) => {
		let nextState = {}
		reducersKeys.forEach(key => {
			let reducer = reducers[key]
			nextState[key] = reducer(state[key], action)
		})
		return nextState
	}
}

export default combineReducers 